<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <div id="time"></div>
    <!-- <div class="aaa"></div> -->
    <script>
      var days = document.querySelector("#time");
      var b = document.body;
      function countDown() {
        // 计算当前时间到2023年的双11的00:00：00的时间差
        var time2 = new Date(2023, 10, 11, 00, 00, 00); //目标时间
        var time1 = new Date(); //现在时间
        var dtime = (time2 - time1) / 1000; //相差时间
        // console.log(dtime)
        var d = Math.floor(dtime / 60 / 60 / 24); //天
        var h = Math.floor((dtime / 60 / 60) % 24); //时
        var m = Math.floor((dtime / 60) % 60); //分
        var s = Math.floor(dtime % 60); //秒
        // return d +'天'+h +'时' + m +'分' +s +'秒';
        days.innerText = `距离2023双十一还有${d}天${h}小时${m}分钟${s}秒`;
        days.style.color = `rgb(${Math.floor(Math.random() * 256)},${Math.floor(
          Math.random() * 256
        )},${Math.floor(Math.random() * 256)})`;
        days.style.fontSize = "60px";
        days.style.width = "660px";
        b.style.backgroundColor = `rgb(${Math.floor(Math.random() * 256)},${Math.floor(
          Math.random() * 256
        )},${Math.floor(Math.random() * 256)})`;
       days.style.transform =  `translate(${Math.floor(Math.random() * 500)}px,${Math.floor(Math.random() * 600)}px)`;
      }
      countDown();
      var res = setInterval(countDown, 1000);
      // console.log(res);

 

    </script>
  </body>
</html>
